import { siderMenu } from '@/api/resource'
import { setSiderMenu, getSiderMenu } from '@/utils/auth'


/*let getHeader = new Promise((resolve, reject) => {  // 头部菜单
		headerMenu().then(response => {
			const data = response.data
			commit('SET_HEADER_MENU', window.JSON.stringify(data))  // window.JSON.stringify(data)
			setHeaderMenu(data)
			resolve(666)
		}).catch(err => {
			reject(err)
		})
 	})*/
/*let getSider = new Promise((resolve, reject) => {  // 左侧菜单
	siderMenu().then(response => {
		const data = response.data
		commit('SET_SIDER_MENU', data)
		setSiderMenu(data)
		resolve
	}).catch(err => {
		reject(err)
	})
	resolve()
})*/

const resource = {
	state: {
		siderMenu: getSiderMenu(),
		button: {}
	},
	mutations: {
		SET_SIDER_MENU: (state, siderMenu) => {
			state.siderMenu = siderMenu
		},
		SET_BUTTON: (state, button) => {
			state.button = button
		}
	},
	actions: {
		GetSiderMenu({ commit, state }) {
			//return Promise.all([getHeader, getSider])
			return new Promise((resolve, reject) => {  // 左侧菜单
				/*siderMenu().then(response => {
					const data = response.data
					commit('SET_SIDER_MENU', window.JSON.stringify(data))  // window.JSON.stringify(data)
					setSiderMenu(window.JSON.stringify(data))
					resolve()
				}).catch(err => {
					reject(err)
				})*/
				setSiderMenu()
				resolve()
			})
		},
	}
}
export default resource